Skip to content

Update IM calc to use NZGMDB IM settings#89

Open
lispandfound wants to merge 24 commits intopegasusfrom
im_calc_nzgmdb_alignment
Open

Update IM calc to use NZGMDB IM settings#89
lispandfound wants to merge 24 commits intopegasusfrom
im_calc_nzgmdb_alignment

Conversation

@lispandfound
Copy link
Contributor

@lispandfound lispandfound commented Feb 16, 2026

Note

Merge #80 and #88 first!

  • Updates the default im calculation periods to match NZGMDB
  • Includes PGD as a default intensity measure

lispandfound and others added 21 commits December 17, 2025 11:04
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…HF input test

- Correct typo in comment for output file placeholder
- Add assertion for rupture velocity parameters line
- Fix typo in comment regarding referential transparency in station seeds test
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- In genslip, the defaults from the source code are 6.5km +/- 1.5km for
shallow transition and are 17.5 +/- 2.5km for deep transition.
- The defaults and bounds calculation has been updated for consistency
Copilot AI review requested due to automatic review settings February 16, 2026 03:11
@gemini-code-assist
Copy link

Summary of Changes

Hello @lispandfound, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the handling of default simulation parameters and intensity measure calculations to align with NZGMDB standards. It introduces a more robust and modular system for managing configuration defaults, particularly for rupture velocity and IM periods, and enhances the high-frequency simulation workflow with new utility functions and comprehensive testing. The changes aim to improve the accuracy and maintainability of seismic simulation settings.

Highlights

  • IM Calculation Settings Update: The default intensity measure (IM) calculation periods have been updated to align with NZGMDB standards, and Peak Ground Displacement (PGD) has been included as a new default intensity measure.
  • Default Parameter Loading Refactor: The system for loading default parameters has been refactored to use a hierarchical merging approach. A new 'root' defaults file provides base parameters, which are then overridden by version-specific defaults, simplifying parameter management and ensuring consistency.
  • Rupture Velocity Parameterization: Rupture velocity parameters have been extracted from the HF configuration into a dedicated RuptureVelocity class and schema, improving modularity and clarity of seismic simulation settings.
  • New HF Simulation Utility Functions and Tests: New utility functions for high-frequency (HF) simulations have been introduced, including rupture_velocity_hf_transition_bands, station_seeds for order-invariant seed generation, and create_hf_dataset for structured xarray dataset creation. Corresponding tests have been added to ensure their correctness.
  • Cleanup of Old Default Parameter Files: Outdated default parameter files and a README for default parameters have been removed, streamlining the configuration directory structure.
Changelog
  • pyproject.toml
    • Added 'types' to deptry's pep621_dev_dependency_groups for improved dependency analysis.
  • tests/test_hf.py
    • Added new test file to validate hf_sim utility functions, including build_hf_input serialization, stable_hash, station_seeds, and create_hf_dataset.
  • tests/test_realisation.py
    • Renamed rvfac_seg to rvfrac_seg in SRFConfig test data.
    • Added RuptureVelocity to the list of tested realisation types.
  • tests/test_realisation_to_srf.py
    • Added new test file to verify the _build_genslip_command function with static arguments.
  • workflow/default_parameters/README.md
    • Removed outdated README file for default parameters.
  • workflow/default_parameters/develop/defaults.yaml
    • Removed rupture velocity parameters (rvfac, rvfac_shal, rvfac_deep) from the hf section.
    • Added a new rupture_velocity section with detailed parameters including rvfrac, rvfrac_shal, rvfrac_deep, shallow_depth, deep_depth, shallow_transition_range, and deep_transition_range.
    • Renamed rvfac_seg to rvfrac_seg in the srf section.
  • workflow/default_parameters/develop/root_defaults.yaml
    • Removed the root_defaults.yaml file from the develop directory.
  • workflow/default_parameters/root/defaults.yaml
    • Added a new root defaults file containing comprehensive default parameters for emod3d, hf, rupture_velocity, srf, velocity_model, velocity_model_1d, im, and hf_velocity_model_1d.
    • Updated IM periods and included PGD as a default intensity measure.
  • workflow/default_parameters/v24_2_2_1/defaults.yaml
    • Removed detailed emod3d, hf, srf, velocity_model, velocity_model_1d, im, and hf_velocity_model_1d sections, retaining only resolution and bb parameters, as these are now handled by the root defaults.
  • workflow/default_parameters/v24_2_2_1/root_defaults.yaml
    • Removed the root_defaults.yaml file from the v24_2_2_1 directory.
  • workflow/default_parameters/v24_2_2_2/defaults.yaml
    • Removed detailed emod3d, hf, srf, velocity_model, velocity_model_1d, im, and hf_velocity_model_1d sections, retaining only resolution and bb parameters, as these are now handled by the root defaults.
  • workflow/default_parameters/v24_2_2_2/root_defaults.yaml
    • Removed the root_defaults.yaml file from the v24_2_2_2 directory.
  • workflow/default_parameters/v24_2_2_4/defaults.yaml
    • Removed detailed emod3d, hf, srf, velocity_model, velocity_model_1d, im, and hf_velocity_model_1d sections, retaining only resolution and bb parameters, as these are now handled by the root defaults.
  • workflow/default_parameters/v24_2_2_4/root_defaults.yaml
    • Removed the root_defaults.yaml file from the v24_2_2_4 directory.
  • workflow/defaults.py
    • Imported Any for type hinting and the new root default parameters module.
    • Added _merge_defaults function for deep merging dictionaries.
    • Modified load_defaults to load and merge root defaults with version-specific defaults.
  • workflow/realisations.py
    • Renamed rvfac_seg to rvfrac_seg in SRFConfig.
    • Added a new RuptureVelocity dataclass to encapsulate rupture velocity parameters.
    • Removed rupture velocity related fields (rvfac, rvfac_shal, rvfac_deep) from HFConfig.
  • workflow/schemas.py
    • Added RUPTURE_VELOCITY_SCHEMA for validating rupture velocity parameters.
    • Renamed rvfac_seg to rvfrac_seg in SRF_SCHEMA.
    • Removed rupture velocity related fields from HF_SCHEMA.
  • workflow/scripts/hf_sim.py
    • Imported Iterable and npt for improved type hinting.
    • Added rupture_velocity_hf_transition_bands function to calculate transition depths.
    • Updated build_hf_input to accept and utilize the new RuptureVelocity object and its transition band parameters.
    • Added station_seeds function for generating order-invariant per-station seeds.
    • Added create_hf_dataset function to create structured xarray Datasets for HF simulation data.
    • Refactored run_hf to use the new RuptureVelocity object and create_hf_dataset function.
  • workflow/scripts/realisation_to_srf.py
    • Imported RuptureVelocity.
    • Added rupture_velocity to SRFRealisationContext and the _build_genslip_command function signature.
    • Updated _build_genslip_command to include rupture velocity parameters in the genslip command arguments.
    • Updated generate_fault_srf and generate_srf to pass the rupture_velocity object.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deptry.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and beneficial refactoring of the default parameter handling, creating a hierarchical structure with a new root defaults file. This greatly improves maintainability by reducing duplication. It also refactors rupture velocity parameters into a new RuptureVelocity configuration class, improving code organization and consistency by renaming rvfac to rvfrac. As described, the intensity measure calculation parameters have been updated to match NZGMDB standards, including the addition of PGD. New tests have been added to cover these changes. I've found one potential issue regarding the handling of empty YAML files which could lead to an error.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors rupture velocity configuration and updates intensity measure calculation defaults to align with NZGMDB standards. It builds on PR #80's rupture velocity refactor by extracting common default parameters into a centralized root configuration file and updating IM calculation periods.

Changes:

  • Extracts rupture velocity parameters (rvfrac, rvfrac_shal, rvfrac_deep, and depth configurations) into a new RuptureVelocity class, removing them from HFConfig
  • Consolidates common default parameters into a new workflow/default_parameters/root/defaults.yaml file with a deep-merge loading strategy
  • Updates intensity measure calculation to include PGD and use NZGMDB-aligned pSA periods (expanded from 31 to 107 periods)

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
workflow/scripts/realisation_to_srf.py Adds RuptureVelocity parameter to SRF generation, passes rupture velocity config to genslip command
workflow/scripts/hf_sim.py Refactors to use RuptureVelocity config, extracts helper functions (rupture_velocity_hf_transition_bands, station_seeds, create_hf_dataset) for better testability
workflow/schemas.py Adds RUPTURE_VELOCITY_SCHEMA, removes rupture velocity fields from HF_CONFIG_SCHEMA, renames rvfac_seg to rvfrac_seg
workflow/realisations.py Adds RuptureVelocity class, removes rupture velocity fields from HFConfig, renames rvfac_seg to rvfrac_seg in SRFConfig
workflow/defaults.py Implements _merge_defaults function for deep-merging root and version-specific defaults
workflow/default_parameters/root/defaults.yaml New centralized defaults file with common configuration (emod3d, hf, rupture_velocity, srf, velocity_model, velocity_model_1d, im, hf_velocity_model_1d)
workflow/default_parameters/v*/root_defaults.yaml All removed (migrated to root/defaults.yaml)
workflow/default_parameters/v*/defaults.yaml Stripped down to only version-specific overrides (resolution, bb parameters)
workflow/default_parameters/develop/defaults.yaml Updated with new rupture_velocity section and rvfrac_seg rename
workflow/default_parameters/README.md Deleted (outdated version documentation)
tests/test_realisation_to_srf.py New test file for genslip command building with rupture velocity parameters
tests/test_realisation.py Adds RuptureVelocity to test_defaults_are_loadable, updates rvfac_seg to rvfrac_seg
tests/test_hf.py New comprehensive test file for HF simulation functions (build_hf_input, stable_hash, station_seeds, create_hf_dataset)
pyproject.toml Adds "types" to pep621_dev_dependency_groups
.github/workflows/deptry.yml Simplifies deptry command (removed explicit dependency group flags)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Qp: 460.00
Qs: 230.00
im:
ims: ["PGA", "PGV", "PGD", "CAV", "AI", "Ds575", "Ds595", "pSA", "FAS"]
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PGD has been added to the default intensity measures list, but there is no handler for it in the im_function_map in workflow/scripts/im_calc.py (which only has handlers for PGA, PGV, CAV, AI, Ds575, Ds595, pSA, and FAS). This will cause intensity measure calculation to fail when PGD is requested. Either remove PGD from the default list or add the corresponding handler to im_calc.py.

Suggested change
ims: ["PGA", "PGV", "PGD", "CAV", "AI", "Ds575", "Ds595", "pSA", "FAS"]
ims: ["PGA", "PGV", "CAV", "AI", "Ds575", "Ds595", "pSA", "FAS"]

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed in #88

@lispandfound
Copy link
Contributor Author

Tests will fail until #88 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants